package auto.test.service;

import org.openqa.selenium.WebDriver;

import auto.test.base.BaseCase;


public class LoginService extends BaseCase{
	
		public HomeHandle homeHandle;
		public LoginHandle loginHandle;
		public HomePage homePage;
	
	    public void Login(WebDriver driver,String exhibitionname,String user,String password) {
	    Getlog();
	  //   ProUtil ProU=new ProUtil("src\\test\\resources\\config\\config.properties");
		 driver.get(GetHost("#/"));
		 homeHandle= new HomeHandle(driver);
		 homePage=new HomePage(driver);
			homeHandle.Sendexhibition(exhibitionname);
			homeHandle.Clickchooseexhibition();
			homeHandle.ClickLoginbutton();
			loginHandle=new LoginHandle(driver);

			loginHandle.Senduser(user);
			loginHandle.SendPassword(password);
			loginHandle.ClickLogin();
//		 WebElement e=homePage.getupdatenotice();
//		 if(e!=null) {
//			 homeHandle.Clickupdatenotice();
//		 }
	/*		try {
				Thread.sleep(2000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			List<WebElement> notice=driver.findElements(By.className("ant-btn-primary"));
			if (notice.size() == 2) {
				notice.get(1).click();

			} else {

			}
		 homeHandle.Sendexhibition(exhibitionname);
		 homeHandle.Clickchooseexhibition();

			try {
				Thread.sleep(2000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			List<WebElement> btn=driver.findElements(By.xpath("//body/div[3]/div[1]/div[2]/div[1]/div[2]/div[2]/div[2]/button[1]"));
			System.out.println(btn.get(0).isDisplayed());
			for (int i=btn.size();i>=0;) {
				if (btn.get(0).isDisplayed()==true) {
					btn.get(0).click();
					try {
						Thread.sleep(2000);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
					btn = driver.findElements(By.xpath("//body/div[3]/div[1]/div[2]/div[1]/div[2]/div[2]/div[2]/button[1]"));
				} else {
					try {
						Thread.sleep(2000);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
					homeHandle.ClickLoginbutton();
					loginHandle=new LoginHandle(driver);
					loginHandle.Senduser(user);
					loginHandle.SendPassword(password);
					loginHandle.ClickLogin();
					break;
				}

			}
*/
//		 WebElement e1=homePage.getupdatenotice();
//		 if(e1!=null) {
//			 homeHandle.Clickupdatenotice();
//		 }

//		 WebElement e2=homePage.getupdatenotice();
//		 if(e2!=null) {
//			 homeHandle.Clickupdatenotice();
//		 }
		
	 }
	
	   
	  
	    
}
